<extend name="./public/frame.html"/>
<block name="content">
	<div class="layer_content">
		<div class="layer_form">
			<div class="down_icon"></div>
			<div class="layer_div">
				<div class="layer_tit">
					手机号：
				</div>
				<div class="layer_control">
					<input type="text" class="w180" id="phone" placeholder="手机号搜索">
				</div>
			</div>
			<div class="layer_div">
				<div class="layer_tit">
					开始时间：
				</div>
				<div class="layer_control">
					<input type="text" class="w180" id="start" placeholder="报警时间（开始）">
				</div>
			</div>
			<div class="layer_div">
				<div class="layer_tit">
					结束时间：
				</div>
				<div class="layer_control">
					<input type="text" class="w180" id="end" placeholder="报警时间（结束）">
				</div>
			</div>
			<div class="button_search">
				<button class="layui-btn" data-type="search" style="float: right;margin-right: 52px;">搜索</button>
			</div>
		</div>
	</div>
	<table class="layui-table" lay-data="{width:'auto', height:'auto', url:'{:url('User/alarm')}', page: true, limit: 10, id:'test'}" lay-filter="test">
		<thead>
		<tr>
			<th lay-data="{field:'orderTypeName', width:80, align:'center'}">类型</th>
			<th lay-data="{field:'uid', width:80, align:'center'}">UID</th>
			<th lay-data="{field:'user_phone', width:120, align:'center'}">手机号</th>
			<th lay-data="{field:'driver_name', width:120, align:'center'}">司机姓名</th>
			<th lay-data="{field:'driver_phone', width:120, align:'center'}">司机号码</th>
			<th lay-data="{field:'alarm_time', width:180, align:'center'}">报警时间</th>
			<th lay-data="{field:'alarm_address', width:200, align:'center'}">报警地点</th>
			<th lay-data="{field:'content', width:260, align:'center'}">处理内容</th>
			<th lay-data="{field:'deal_time', width:180, align:'center'}">处理时间</th>
			<th lay-data="{fixed:'right', toolbar: '#barDemo', width:120, align:'center'}">操作</th>
		</tr>
		</thead>
	</table>

	<div class="layui-hide" id="barDemo">
		{{# if(d.is_deal == 1){ }}
			<a lay-event="deal">已处理</a>
		{{# }else{ }}
			<a lay-event="deal" style="color: red">未处理</a>
		{{# } }}
		<a lay-event="look">详情</a>
		<!--<a lay-event="local">当前位置</a>-->
	</div>
	<script>
		layui.use(['table','laydate'], function () {
			var table = layui.table,laydate = layui.laydate;
			laydate.render({
				elem: '#start' //指定元素
				,type: 'datetime'
				,theme: '#393D49'
			});
			laydate.render({
				elem: '#end' //指定元素
				,type: 'datetime'
				,theme: '#393D49'
			})
			//监听工具条
			table.on('tool(test)', function (obj) {
				var data = obj.data;
                var alarm_id = data.alarm_id;
				if (obj.event === 'deal') {
					layer.prompt({
						formType: 2,
						value: '',
						title: '一键报警处理'
					}, function(value, index, elem){
						layer.close(index);
						$.post('/admin/User/alarm_ajax',{'alarm_id':alarm_id,'content':value},function(res){
                            switch (res['status']){
                                case 1:
                                    layer.alert(res['msg'],{icon: 1},function (ind) {
                                        location.reload();
                                        layer.close(ind);
                                    });
                                    break;
                                default:
                                    layer.alert(res['msg'],{icon: 5});
                                    break;
                            }
						},'json')
					});
				}
				else if (obj.event === 'look') {
                    layer.open({
                        type: 2,
                        title: '订单信息详情',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['90%', '90%'],
                        content: '{:url("/admin/user/alarm_look","alarm_id=")}' + alarm_id //iframe的url
                    });
                }
				/*else if (obj.event === 'local') {
                    layer.open({
                        type: 2,
                        title: '当前用户位置',
                        shadeClose: true,
                        shade: 0.8,
                        area: ['100%', '100%'],
                        content: '{:url("/admin/user/alarm_local","alarm_id=")}' + alarm_id //iframe的url
                    });
                }*/
			});
			$('.layui-btn').on('click', function () {
				var phone 	= $("#phone").val();
				var start 	= $("#start").val();
				var end 	= $("#end").val();
				table.reload('test', {
					url: '/admin/user/alarm', where: {
						"user_phone": phone,
						"start_time": start,
						"end_time": end
					}
				});
			})
		});
	</script>
</block>
